package com.roger.myHome.service.impl;

import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.roger.myHome.domain.TbUsers;
import com.roger.myHome.mapper.UsersMapper;
import com.roger.myHome.service.EhcacheService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class EhcacheServiceImpl implements EhcacheService {
    @Resource
    private UsersMapper usersMapper;

    @Override
    @Cacheable(value = "users",keyGenerator  = "myKeyGenerator")
    public List queryUserList(Integer id){
        System.out.println("从数据库获取");

        QueryWrapper<TbUsers> wrapper = new QueryWrapper<>();
        wrapper.eq("id", id);
        return usersMapper.selectList(wrapper);
    }
}
